package com.exam.master.model.main.adapter;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.exam.commonbiz.bean.MessageInfo;
import com.exam.commonbiz.util.OnFastClickListener;
import com.exam.master.R;

public class HomeMessageAdapter extends BaseQuickAdapter<MessageInfo, BaseViewHolder> {

    private OnItemClickListener listener;

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        listener = onItemClickListener;
    }

    public HomeMessageAdapter() {
        super(R.layout.item_layout_home_message, null);
    }

    @Override
    protected void convert(BaseViewHolder helper, MessageInfo item) {

        helper.setText(R.id.tv_name, item.nickname);
        helper.setText(R.id.tv_content, item.content);
        helper.setText(R.id.tv_time, item.createDate);

        helper.itemView.setOnClickListener(new OnFastClickListener() {
            @Override
            public void onFastClick(View v) {
                if (listener != null) {
                    listener.onItemClick(item);
                }
            }
        });
    }

    public interface OnItemClickListener {
        void onItemClick(MessageInfo messageInfo);
    }
}
